package WaiBao;

import java.util.Arrays;

public class DenDongZou {
    public static void main(String[] args) {
        String[] name = {"郭敬明(班长)", "郭富城(团支书)", "小李(学习委员)", "李大壮(体育委员)", "何晨光", "王玉辉", "李星", "刘志阳", "王新凯", "郭首听", "赵星星", "赵大宝",
                "王昭君", "貂蝉", "西施", "妲己", "安琪拉", "米莱迪", "奕星", "赵云", "黄忠", "关羽", "东方耀", "东方镜", "孙悟空", "猪八戒", "沙和尚", "唐僧",
                "王靖雯", "邓栋州(心理委员)"};//考生本人:邓栋州(心理委员)
        int[] age = {20,18,20, 21,18,21, 20, 18, 18, 21, 21, 19, 18, 20, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 22, 18, 20, 21};//考生年龄：21

        double[] chatou1 = {89, 74, 59, 85, 74, 68, 71, 80, 68, 80, 90, 77, 85, 79, 64, 68, 69, 99, 96, 80, 92, 91, 90, 85, 75, 74, 74, 84, 87, 96};
        double[] chatou2 = {69, 82, 80, 86, 76, 86, 74, 83, 69, 74, 94, 67, 84, 75, 95, 65, 86, 79, 66, 78, 82, 71, 85, 87, 75, 89, 74, 70, 85, 96};
        double[] chatou3 = {81, 83, 99, 74, 85, 75, 63, 69, 80, 69, 73, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 74, 95};


        double yingxiang1;//代表每个学生的总分
        double yingxiang2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            yingxiang1 =  chatou1[i] + chatou2[i] + chatou3[i];
//            yingxiang2 = (yingxiang1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +yingxiang1);
//            System.out.println(name[i] + "的平均分为:" + yingxiang2);
//        }


        double caomei = 0, digua = 0;
        double[] heizi = new double[30];
//        for (int i = 0; i < 30; i++) {
//            caomei = chatou1[i] +  chatou2[i] + chatou3[i];
//            digua  = (caomei * 1.0) / 3;
//            heizi[i] = digua;
//        }
//
//        for (int i = 0; i <heizi.length - 1; i++) {
//            for (int j = 0; j < heizi.length - i - 1; j++) {
//                if (heizi[j] < heizi[j + 1]) {
//                    double tep =heizi[j];
//                    heizi[j] =heizi[j + 1];
//                    heizi[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(heizi[i]);
//        }


        double huawei1 = 0,huawei2 = 0, huawei3 = 0;//计算每门课的平均分
        double pingguo1 = 0,pingguo2 = 0,pingguo3 = 0;//计算每门课标准差
        double manguo1 = 0, manguo2 = 0, manguo3 = 0;//计算每门课中位数
        double sap = 0;
        for (int i = 0; i < chatou1.length; i++) {
            sap+=chatou1[i];
        }
        huawei1 = (sap*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+ huawei1);
        double Sum = 0;
        for (int i = 0; i < chatou2.length; i++) {
            Sum+=chatou2[i];
        }
        huawei2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+huawei2);
        double sum = 0;
        for (int i = 0; i <chatou3.length; i++) {
            sum+=chatou3[i];
        }
        huawei3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+huawei3);




        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i <chatou1.length; i++) {
            c1+= (chatou1[i] - huawei1)*(chatou1[i] - huawei1);
        }
        pingguo1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+pingguo1);

        for (int i = 0; i <chatou2.length; i++) {
            c2+= (chatou2[i] - huawei2)*(chatou2[i] -huawei2);
        }
        pingguo2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+pingguo2);

        for (int i = 0; i <chatou3.length; i++) {
            c3+= (chatou3[i] - huawei3)*(chatou3[i] - huawei3);
        }
        pingguo3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+pingguo3);
//////////
////////
////////
//        Arrays.sort(chatou1);
//        Arrays.sort(chatou2);
//        Arrays.sort(chatou3);
//        manguo1 =( chatou1[14]+chatou1[15])*1.0/2;
//        manguo2 =(chatou2[14]+chatou2[15])*1.0/2;
//        manguo3 =( chatou3[14]+chatou3[15])*1.0/2;
//        System.out.println("分析化学的中位数为:"+  manguo1);
//        System.out.println("线性代数的中位数为:"+ manguo2);
//        System.out.println("有机化学学的中位数为:"+ manguo3);




    }
}
